package com.demohomework.homeworkdemo.service.impl;

import com.demohomework.homeworkdemo.mapper.AssSubmitMapper;
import com.demohomework.homeworkdemo.mapper.AssignmentMapper;
import com.demohomework.homeworkdemo.pojo.AssSubmit;
import com.demohomework.homeworkdemo.service.AssSubmitService;
import com.demohomework.homeworkdemo.util.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class AssSubmitServiceImpl implements AssSubmitService {
    @Autowired
    private AssSubmitMapper assSubmitMapper;
    @Override
    // 这里的id是学生的id，不是作业的id
    public void add(AssSubmit assSubmit) {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
        assSubmit.setStuId(id);
        assSubmitMapper.add(assSubmit);
    }

    //查看自己的作业
    @Override
    public List<AssSubmit> list() {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
        return assSubmitMapper.list(id);
    }

    @Override
    public AssSubmit findId(Integer id) {
        return assSubmitMapper.findId(id);
    }

    @Override
    public void update(AssSubmit assSubmit) {
        assSubmitMapper.update(assSubmit);
    }

    @Override
    public void delete(AssSubmit assSubmit) {
         assSubmitMapper.delete(assSubmit);
    }

    @Override
    public List<AssSubmit> search(Integer assId) {
        return assSubmitMapper.search(assId);
    }

    @Override
    public List<AssSubmit> searchByStudentId(Integer stuId) {
        return assSubmitMapper.searchByStudentId(stuId);
    }


}
